package xcmg.device.dao.mapper.warehouse;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.warehouse.allot.RegionAllotDetailDO;
import xcmg.device.service.vo.boxup.BoxupDetailVO;
import xcmg.device.service.vo.boxup.BoxupMaterialsQuery;
import xcmg.device.service.vo.delivery.BillDetailMaterialsVO;
import xcmg.device.service.vo.delivery.BoxUpDeliveryNoteVO;
import xcmg.device.service.vo.warehouse.allot.RegionAllotAmountVO;
import xcmg.device.service.vo.warehouse.allot.RegionAllotDetailVO;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface RegionAllotDetailMapper {
    int deleteByPrimaryKey(String id);

    int insert(RegionAllotDetailDO record);

    RegionAllotDetailDO selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(RegionAllotDetailDO record);

    int updateByPrimaryKey(RegionAllotDetailDO record);

    int removeByAllotOrderList(@Param("orderList") List<String> orderList, @Param("orgId") String orgId);

    List<RegionAllotDetailDO> findByAllotOrderList(@Param("orderList") List<String> orderList, @Param("orgId") String orgId);

    List<RegionAllotDetailDO> findByAllotOrderListForLocationUser(@Param("orderList") List<String> orderList, @Param("orgId") String orgId);

    List<RegionAllotDetailDO> list(RegionAllotDetailVO condition);

    List<RegionAllotDetailDO> listByBillNo(@Param("billNo") String billNo, @Param("orgId") String orgId);

    int deleteNotComplete(@Param("allotOrder") String allotOrder, @Param("orgId") String orgId);

    int findOutState(@Param("allotOrder") String allotOrder, @Param("orgId") String orgId);

    int updateInStatus(@Param("status") int status, @Param("billNo") String billNo,@Param("materialsNo") String materialsNo);

    int updateOutStatus(@Param("status") int status, @Param("billNo") String billNo,@Param("materialsNo") String materialsNo);

    BoxUpDeliveryNoteVO itemByNoAndMaterialsNo(@Param("orgId")String orgId, @Param("deliveryNoteNo")String deliveryNoteNo, @Param("materialsNo") String materialsNo);

    List<BoxupDetailVO> notPackList(BoxupMaterialsQuery boxupMaterialsQuery);

    List<BillDetailMaterialsVO> moreBillDetail(@Param("deliveryBillId")String deliveryBillId);

    List<RegionAllotDetailDO> listForRemove(@Param("billNo") String billNo, @Param("orgId") String orgId, @Param("ids") List<String> ids);

    RegionAllotDetailDO getByMaterialsNo(@Param("materialNo") String materialNo, @Param("allotOrder")String allotOrder);

    int updatePostOutAmount(@Param("billNo")String billNo, @Param("materialNo")String materialNo , @Param("orgId") String orgId, @Param("voucherOutNo")String voucherOutNo);

    int updatePostInAmount(@Param("billNo")String billNo, @Param("materialNo")String materialNo , @Param("orgId") String orgId, @Param("voucherInNo")String voucherInNo);

    int findPostOutStatus(@Param("billNo")String billNo);

    int findPostInStatus(@Param("billNo")String billNo);

    int updatePostOutStatus(@Param("billNo")String billNo, @Param("postStatus")int postStatus);

    int updatePostInStatus(@Param("billNo")String billNo, @Param("postStatus")int postStatus);

    int updateVoucherOutNoNone(@Param("billNo")String billNo, @Param("materialsNo") String materialsNo);

    /**
     * 统计调拨计划零件已创建区域调拨单的相关数量
     *
     * @param allotPlanId
     * @param materialsNo
     * @return
     */
    RegionAllotAmountVO countAllotAmount(@Param("allotPlanId")String allotPlanId, @Param("materialsNo")String materialsNo);

    List<RegionAllotAmountVO> countAllotAmountByMaterialsNos(@Param("allotPlanId")String allotPlanId, @Param("materialsNoList")List<String> materialsNoList);

    BigDecimal findSumAmountByOrders(List<String> allotOrderList);

    BigDecimal findSumInAmountByPlanOrderAndMaterialNo(@Param("allotPlanOrder") String allotPlanOrder,@Param("materialNo") String materialNo);

    BigDecimal findSumOutAmountByPlanOrderAndMaterialNo(@Param("allotPlanOrder") String allotPlanOrder,@Param("materialNo") String materialNo);

    BigDecimal findSumInAmountByAllotOrderAndMaterialNo(@Param("allotOrder") String allotOrder,@Param("materialNo") String materialNo);

    BigDecimal findSumOutAmountByAllotOrderAndMaterialNo(@Param("allotOrder") String allotOrder,@Param("materialNo") String materialNo);

    List<RegionAllotDetailDO> getMaterialInfoByNo(List<String> billNoList);
}
